
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
	<link rel=stylesheet href='include/hoj.css' type='text/css'>
</head>
<body>
<center>
<div style="width:90%; text-align:left">
<img src="image/logo.png"/>
</div>
<table width=96%> 
	<tr align="center" class='hd' valign="top">
				<th><a href="faqs.php">F.A.Qs</a></th>
		<th><a href="./bbs.php">Web Board</a></th>
		<th><a href="./">Home</a></th>
		<th><a href="./problemset.html">ProblemSet</a></th>
		<th><a href="./status.php">Status</a></th>
		<th><a href="./ranklist.php">Ranklist</a></th>
		<th><a href="./contest.php">Contest</a></th>
		<th><a href=loginpage.php>Login</a></th><th><a href=registerpage.php>Register</a></th>	</tr>
</table>
</center>
<center>
<div class="notice">
	<div>
		<B>Notice:</B>鉴于种种原因，本OJ自下周星期一（3月5号）开始不再全面开放，请各位做好善后事宜，谢谢合作。	</div>
</div>
</center>
</div>
<title>Problem 2449. -- 统计解个数 -- 衡阳八中OJ离线版-2012-02-29</title><center><h2>2449: 统计解个数</h2><span class=green>Time Limit: </span>1 Sec&nbsp;&nbsp;<span class=green>Memory Limit: </span>128 MB<br><span class=green>Submit: </span>2&nbsp;&nbsp;<span class=green>Solved: </span>1<br>[<a href='submitpage.php?id=2449'>Submit</a>][<a href='problemstatus.php?id=2449'>Status</a>][<a href='bbs.php?id=2449'>Discuss</a>]</center><h2>Description</h2><div class=content><div style="text-indent: 21pt"><span style="font-size: 12pt">给定函数</span><span style="font-size: 12pt">f(x) </span><span style="font-size: 12pt">，它在</span><span style="font-size: 12pt">[k,k+1]</span><span style="font-size: 12pt">上是线性的，</span><span style="font-size: 12pt">x</span><span style="font-size: 12pt">是整数时，</span><span style="font-size: 12pt">f(x)</span><span style="font-size: 12pt">也是整数。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 12pt">即当</span><span style="font-size: 12pt">k</span><span style="font-size: 12pt">是整数时，</span><span style="font-size: 12pt">x</span><span style="font-size: 12pt">属于</span><span style="font-size: 12pt">[k,k+1]</span><span style="font-size: 12pt">，</span><span style="font-size: 12pt">f(x)=(k+1-x)f(k)+(x-k)f(k+1)</span><span style="font-size: 12pt">。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 12pt">记</span><span style="font-size: 12pt">f^1(x)=f(x),f^n(x)=f(f^(n-1)(x))</span><span style="font-size: 12pt">。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 12pt">给出</span><span style="font-size: 12pt">f(0),f(1),...,f(m)</span><span style="font-size: 12pt">，求</span><span style="font-size: 12pt">f^n(x)=x </span><span style="font-size: 12pt">，</span><span style="font-size: 12pt">x</span><span style="font-size: 12pt">属于</span><span style="font-size: 12pt">[0,m]</span><span style="font-size: 12pt">的解的个数。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 12pt">多组数据。</span></div>
<div style="text-indent: 21pt"><sup>&nbsp;</sup></div></div><h2>Input</h2><div class=content><div style="text-indent: 21pt"><span style="font-size: 10.5pt">对于每组数据：</span></div>
<div style="text-indent: 21pt"><span style="font-size: 10.5pt">第一行读入一个数</span><span style="font-size: 10.5pt">m</span><span style="font-size: 10.5pt">。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 10.5pt">第二行读入</span><span style="font-size: 10.5pt">m+1</span><span style="font-size: 10.5pt">个数，第</span><span style="font-size: 10.5pt">i</span><span style="font-size: 10.5pt">个数表示</span><span style="font-size: 10.5pt">f(i-1)</span><span style="font-size: 10.5pt">。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 10.5pt">第三行读入两个数</span><span style="font-size: 10.5pt">n</span><span style="font-size: 10.5pt">和</span><span style="font-size: 10.5pt">modnum</span><span style="font-size: 10.5pt">，</span><span style="font-size: 10.5pt">modnum</span><span style="font-size: 10.5pt">表示答案需要</span><span style="font-size: 10.5pt">mod modnum</span><span style="font-size: 10.5pt">。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 10.5pt">相邻两组数据中有一个空行。</span></div>
<div style="text-indent: 21pt"><span style="font-size: 10.5pt">最后以</span><span style="font-size: 10.5pt">0</span><span style="font-size: 10.5pt">结束。</span></div>
<div style="text-indent: 21pt">&nbsp;</div>
<div style="text-indent: 21pt"></div>
<div>&nbsp;</div></div><h2>Output</h2><div class=content><div style="text-indent: 21pt"><span style="font-size: 10.5pt">对于每组数据输出一行表示答案。如果有无穷多个输出</span><span style="font-size: 10.5pt">Infinity</span><span style="font-size: 10.5pt">。</span></div>
<div style="text-indent: 21pt">&nbsp;</div>
<div></div>
<div>&nbsp;</div></div><h2>Sample Input</h2>
			<div class=content><span class=sampledata>2<br />
2 0 2<br />
2 10<br />
 <br />
3<br />
0 1 3 2<br />
1 137<br />
 <br />
3<br />
2 3 0 3<br />
20 10000<br />
 <br />
0<br />
 <br />
</span></div><h2>Sample Output</h2>
			<div class=content><span class=sampledata>4<br />
Infinity<br />
9074<br />
 <br />
 <br />
 </span></div><h2>HINT</h2>
			<div class=content><p><p>对于100%，n&lt;=5000,m&lt;=80,modnum&lt;=10000。<br /><br />
</p></p></div><h2>Source</h2>
			<div class=content><p><a href='problemset.html?search=2011福建集训'>2011福建集训</a></p></div><center>[<a href='submitpage.php?id=2449'>Submit</a>][<a href='problemstatus.php?id=2449'>Status</a>][<a href='bbs.php?id=2449'>Discuss</a>]</center>﻿<br>

<a href="./"><span class=red>HOME</span></a>
<a href="javascript:history.go(-1)"><span class=red>Back</span></a>

<hr>
<center>
	<div class="footer">
			<a href=setlang.php?lang=ko>한국어</a>&nbsp;
		<a href=setlang.php?lang=cn>中文</a>&nbsp;
		<a href=setlang.php?lang=fa>فارسی</a>&nbsp;
		<a href=setlang.php?lang=en>English</a>&nbsp;
		<a href=setlang.php?lang=th>ไทย</a>
	<br>		<div>版权所有 &copy;2008-2012 WaterPark Organization. | <script src="http://s21.cnzz.com/stat.php?id=2982771&web_id=2982771" language="JavaScript"></script>
</div>
		<div>Based on opensource project <a href="http://hustoj.googlecode.com">hustoj</a>.</div>
	</div>
</center>
</body>
</html>
